//
//  AirCondition.m
//  Work1
//
//  Created by cora1n on 14-8-15.
//  Copyright (c) 2014年 devwu. All rights reserved.
//

#import "AirCondition.h"
#import "Room.h"
@implementation AirCondition
//keyPath  监听的键
//object   被监听的对象
-(void)observeValueForKeyPath:(NSString *)keyPath
                     ofObject:(id)object
                       change:(NSDictionary *)change
                      context:(void *)context
{
    //判断对象是否是某一个类的实例变量
    if ([object isMemberOfClass:[Room class ]]) {
        //把被监听的对象由 NSObject类型强制转换为 Room对象
        Room * room = (Room*)object;
        if ([[object valueForKey:@"temp"] intValue]>28) {
            [self.button doButton];
//            [self airConditionSwitch];
        }
        if (room.temp < 22) {
            [self.button doButton];
//            [self airConditionSwitch];
        }
    }
}
-(void)airConditionSwitch
{
    NSLog(@"空调(开机/关机)");
}
@end
